package cn.kpi.service.sys.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.kpi.dao.sys.AccountDao;
import cn.kpi.entity.sys.MenuEntity;
import cn.kpi.entity.sys.RoleEntity;
import cn.kpi.entity.sys.UserEntity;
import cn.kpi.service.sys.IAccountService;

@Service
public class AccountServiceImpl implements IAccountService {
	@Autowired
	private AccountDao accountDao;
	
	
	public UserEntity UserLogin(String username)throws Exception{
		try{
			return accountDao.UserLogin(username);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public List<MenuEntity> GetMenuByUserId(Long userid)throws Exception{
		try{
			return accountDao.GetMenuByUserId(userid);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public int ChangePwd(Long userid,String userpwd)throws Exception{
		try{
			return accountDao.ChangePwd(userid,userpwd);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return -1;
		}
	}
	public List<RoleEntity> GetRoleByUserId(Long userid)throws Exception{
		try{
			return accountDao.GetRoleByUserId(userid);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public String GetOrgidsByRoleId(Long userid,Long orgid)throws Exception{
		try{
			return accountDao.GetOrgidsByRoleId(userid,orgid);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	
	public String GetOrgidsByUserRoleId(Long roleid)throws Exception{
		try{
			return accountDao.GetOrgidsByUserRoleId(roleid);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
}
